package com.czxy.dem01;

import java.util.ArrayList;
import java.util.List;

public class Test10 {
//字符串数组strs中包含字符串{"12","345","6789","1","123","4567"}，创建2个ArrayList集合，
// 遍历strs数组，并判断数组中每一个元素的长度，
// 将长度为偶数和长度为奇数的元素存入到两个集合中，最终将这个两个集合在控制台打印输出：打印格式如下：
    public static void main(String[] args) {
         String[] strs = {"12","345","6789","1","123","4567"};
        List<String> listJ = new ArrayList<>();
        List<String> listO = new ArrayList<>();
        for (int i = 0; i < strs.length; i++) {
            if (strs[i].length()%2==0) {
                listO.add(strs[i]);
            }else {
                listJ.add(strs[i]);
            }
        }
        for (String s : listO) {
            System.out.println("偶数长度字符串："+s+" ");
        }
        for (String s : listJ) {
            System.out.println("奇数长度字符串："+s+" ");
        }
    }
}
